HAL UART control functions migration ¶
This section provides information about the HAL UART control functions migration.
multi-processor mode ¶
Enable/disable mute mode ¶
Function renamed in HAL2.
|
HAL1 |
HAL2 |
|---|---|
HAL_MultiProcessor_EnableMuteMode(UART_HandleTypeDef *huart);
HAL_MultiProcessor_DisableMuteMode(UART_HandleTypeDef *huart);
|
HAL_UART_EnableMultiProcessorMode(const hal_uart_handle_t *huart);
HAL_UART_DisableMultiProcessorMode(const hal_uart_handle_t *huart);
|
Enter Mute Mode ¶
Function renamed in HAL2.
|
HAL1 |
HAL2 |
|---|---|
void HAL_MultiProcessor_EnterMuteMode(UART_HandleTypeDef *huart);
|
hal_status_t HAL_UART_EnterMultiProcessorMuteMode(const hal_uart_handle_t *huart);
|
Set address length ¶
|
HAL1 |
HAL2 |
|---|---|
HAL_MultiProcessorEx_AddressLength_Set(UART_HandleTypeDef *huart,
uint32_t AddressLength)
|
In HAL2, the function has been removed, and the setting of the address length will be added to the
|
Note
The configuration of the address length is applicable only when the wake-up method is based on the address.
Usage Sequence: Wake-up Method: Address Mark ¶
|
HAL1 Usage |
HAL2 Usage |
|---|---|
UART_HandleTypeDef hUARTx;
HAL_MultiProcessor_Init(&hUARTx, 0x29, UART_WAKEUPMETHOD_ADDRESSMARK);
HAL_MultiProcessorEx_AddressLength_Set(&hUARTx, UART_ADDRESS_DETECT_7B);
/* Enable mute mode */
HAL_MultiProcessor_EnableMuteMode(&hUARTx);
/* Enter mute mode */
HAL_MultiProcessor_EnterMuteMode(&hUARTx);
|
hal_uart_handle_t hUARTx;
// Add init and config for UART instance
hal_uart_multi_processor_mode_wakeup_config_t m_multi_proc_config;
m_multi_proc_config.wakeup_method = HAL_UART_WAKEUP_METHOD_ADDRESS_MARK;
m_multi_proc_config.address = 0x29;
m_multi_proc_config.address_length = HAL_UART_ADDRESS_DETECT_7_BIT;
HAL_UART_SetConfigMultiProcessorMode(&hUARTx, &m_multi_proc_config);
/* Enable mute mode */
HAL_UART_EnableMultiProcessorMode(&hUARTx);
/* Enter mute mode */
HAL_UART_EnterMultiProcessorMuteMode(&hUARTx);
|
Usage Sequence: Wake-up Method: Idle Line ¶
|
HAL1 Usage |
HAL2 Usage |
|---|---|
UART_HandleTypeDef hUARTx;
HAL_MultiProcessor_Init(&hUARTx, 0x0, UART_WAKEUPMETHOD_IDLELINE);
/* Enable mute mode */
HAL_MultiProcessor_EnableMuteMode(&hUARTx);
/* Enter mute mode */
HAL_UART_EnableMultiProcessorMode(&hUARTx);
|
hal_uart_handle_t hUARTx;
// Add init and config for UART instance
hal_uart_multi_processor_mode_wakeup_config_t m_multi_proc_config;
m_multi_proc_config.wakeup_method = HAL_UART_WAKEUP_METHOD_IDLE_LINE;
HAL_UART_SetConfigMultiProcessorMode(&hUARTx, &m_multi_proc_config);
/* Enable mute mode */
HAL_UART_EnableMultiProcessorMode(&hUARTx);
/* Enter mute mode */
HAL_MultiProcessor_EnterMuteMode(&hUARTx);
|
Stop Mode ¶
UART stop mode wake-up source configuration ¶
In HAL2, wake-up source configuration is split into three functions for precise control over source selection, address detection length, and address setting.
|
HAL1 |
HAL2 |
|---|---|
HAL_UARTEx_StopModeWakeUpSourceConfig(UART_HandleTypeDef *huart,
UART_WakeUpTypeDef WakeUpSelection);
|
// Configure the wake-up source in stop mode
HAL_UART_SetStopModeWkUpSource(const hal_uart_handle_t *huart,
const hal_uart_wakeup_source_t source);
// Set the address detection length for wake-up
HAL_UART_SetStopModeWkUpAddrLength(const hal_uart_handle_t *huart,
const hal_uart_address_detect_length_t address_length);
// Set the specific address for wake-up
HAL_UART_SetStopModeWkUpAddr(const hal_uart_handle_t *huart,
uint8_t address);
|
Enable/disable stop mode ¶
Function renamed in HAL2.
|
HAL1 |
HAL2 |
|---|---|
HAL_UARTEx_EnableStopMode(UART_HandleTypeDef *huart);
HAL_UARTEx_DisableStopMode(UART_HandleTypeDef *huart);
|
HAL_UART_EnableStopMode(const hal_uart_handle_t *huart);
HAL_UART_DisableStopMode(const hal_uart_handle_t *huart);
|
Usage Sequence:Stop mode ¶
|
HAL1 Usage Sequence |
HAL2 Usage Sequence |
|---|---|
UART_HandleTypeDef hUARTx;
// Add init and config for UART instance
UART_WakeUpTypeDef wake_up_selection;
wake_up_selection.WakeUpEvent = UART_WAKEUP_ON_ADDRESS;
wake_up_selection.AddressLength = UART_ADDRESS_DETECT_4B;
wake_up_selection.Address = 0x29;
HAL_UARTEx_StopModeWakeUpSourceConfig(&hUARTx, wake_up_selection);
/* Enable MCU wake-up by UART */
HAL_UARTEx_EnableStopMode(&hUARTx);
|
hal_uart_handle_t hUARTx;
// Add init and config for UART instance
HAL_UART_SetStopModeWkUpSource(&hUARTx, HAL_UART_WAKEUP_ON_ADDRESS);
HAL_UART_SetStopModeWkUpAddrLength(&hUARTx, HAL_UART_ADDRESS_DETECT_4_BIT);
HAL_UART_SetStopModeWkUpAddr(&hUARTx, 0x29);
/* Enable MCU wake-up by UART */
HAL_UART_EnableStopMode(&hUARTx);
|
Autonomous mode configuration ¶
Set configuration ¶
Configuration of autonomous mode is split into three functions in HAL2.
|
HAL1 |
HAL2 |
|---|---|
HAL_UARTEx_SetConfigAutonomousMode(UART_HandleTypeDef *huart,
const UART_AutonomousModeConfTypeDef *sConfig)
|
// Set the configuration for packet trigger
HAL_UART_AM_SetConfigPacketTrigger(const hal_uart_handle_t *huart,
const hal_uart_am_trig_config_t *p_config)
// Enable packet trigger
HAL_UART_AM_EnablePacketTrigger(const hal_uart_handle_t *huart)
// Optionally enable idle state
HAL_UART_AM_EnableIdle(const hal_uart_handle_t *huart)
|
Get configuration ¶
Function renamed in HAL2.
|
HAL1 |
HAL2 |
|---|---|
HAL_UARTEx_GetConfigAutonomousMode(const UART_HandleTypeDef *huart,
UART_AutonomousModeConfTypeDef *sConfig)
|
HAL_UART_AM_GetConfigPacketTrigger(const hal_uart_handle_t *huart,
hal_uart_am_trig_config_t *p_config)
|
Clear configuration ¶
|
HAL1 |
HAL2 |
|---|---|
HAL_UARTEx_ClearConfigAutonomousMode(UART_HandleTypeDef *huart)
|
Function removed in HAL2 (use instead HAL_UART_AM_DisablePacketTrigger()
and HAL_UART_SetConfig() with default settings ).
|
Usage Sequence: Autonomous mode ¶
|
HAL1 |
HAL2 |
|---|---|
UART_HandleTypeDef huart1;
UART_AutonomousModeConfTypeDef uart_am_config;
// Add init and config for UART instance
// Set configuration for autonomous mode
uart_am_config.AutonomousModeState = UART_AUTONOMOUS_MODE_ENABLE;
uart_am_config.TriggerSelection = UART_GPDMA1_CH0_TCF_TRG;
uart_am_config.TriggerPolarity = UART_TRIG_POLARITY_RISING;
uart_am_config.DataSize = 0;
uart_am_config.IdleFrame = UART_IDLE_FRAME_ENABLE;
HAL_UARTEx_SetConfigAutonomousMode(&huart1, &uart_am_config);
// Optionally get configuration
HAL_UARTEx_GetConfigAutonomousMode(&huart1, &uart_am_config);
// Optionally clear configuration
HAL_UARTEx_ClearConfigAutonomousMode(&huart1);
|
hal_uart_handle_t huart1;
hal_uart_am_trig_config_t uart_am_config;
// Add init and config for UART instance
// Set configuration for packet trigger
uart_am_config.source = HAL_UART_AM_TRIG_GPDMA1_CH0_TC;
uart_am_config.trigger_polarity = HAL_UART_AM_TRIG_RISING;
uart_am_config.packet_size_byte = 0U;
HAL_UART_AM_SetConfigPacketTrigger(&huart1, &uart_am_config);
// Enable packet trigger
HAL_UART_AM_EnablePacketTrigger(&huart1 )
// Enable idle state
HAL_UART_AM_EnableIdle(&huart1);
// Optionally get configuration
HAL_UART_AM_GetConfigPacketTrigger(&huart1, &uart_am_config);
// Optionally clear configuration
HAL_UART_AM_DisablePacketTrigger(&huart1);
|
UART Receiver timeout ¶
Receiver timeout configuration ¶
Function renamed in HAL2.
|
HAL1 |
HAL2 |
|---|---|
void HAL_UART_ReceiverTimeout_Config(UART_HandleTypeDef *huart,
uint32_t TimeoutValue)
|
hal_status_t HAL_UART_SetConfigReceiverTimeout(const hal_uart_handle_t *huart,
uint32_t timeout_bit)
|
Enable/disable receiver timeout ¶
Function renamed in HAL2.
|
HAL1 |
HAL2 |
|---|---|
HAL_UART_EnableReceiverTimeout(UART_HandleTypeDef *huart)
HAL_SttusTypeDef HAL_UART_DisableReceiverTimeout(UART_HandleTypeDef *huart)
|
HAL_UART_EnableReceiverTimeout(const hal_uart_handle_t *huart)
HAL_UART_DisableReceiverTimeout(const hal_uart_handle_t *huart)
|
Send LIN break ¶
Function renamed in HAL2.
|
HAL1 |
HAL2 |
|---|---|
HAL_LIN_SendBreak(UART_HandleTypeDef *huart)
|
HAL_UART_SendLINBreak(hal_uart_handle_t *huart)
|
Enable/disable transmitter ¶
Function renamed in HAL2.
|
HAL1 |
HAL2 |
|---|---|
HAL_HalfDuplex_EnableTransmitter(UART_HandleTypeDef *huart)
HAL_HalfDuplex_EnableReceiver(UART_HandleTypeDef *huart)
|
HAL_UART_EnableTransmitter(const hal_uart_handle_t *huart)
HAL_UART_DisableTransmitter(const hal_uart_handle_t *huart)
|
UART fifo mode ¶
Enable/disable fifo mode ¶
Function renamed in HAL2.
|
HAL1 |
HAL2 |
|---|---|
HAL_UARTEx_EnableFifoMode(UART_HandleTypeDef *huart)
HAL_UARTEx_DisableFifoMode(UART_HandleTypeDef *huart)
|
HAL_UART_EnableFifoMode(const hal_uart_handle_t *huart)
HAL_UART_DisableFifoMode(const hal_uart_handle_t *huart)
|
Set fifo threshold ¶
Function renamed in HAL2.
|
HAL1 |
HAL2 |
|---|---|
HAL_UARTEx_SetTxFifoThreshold(UART_HandleTypeDef *huart,
uint32_t Threshold)
HAL_UARTEx_SetRxFifoThreshold(UART_HandleTypeDef *huart,
uint32_t Threshold)
|
HAL_UART_SetTxFifoThreshold(hal_uart_handle_t *huart,
hal_uart_fifo_threshold_t tx_fifo_threshold)
HAL_UART_SetRxFifoThreshold(hal_uart_handle_t *huart,
hal_uart_fifo_threshold_t rx_fifo_threshold)
|
Get RX Event Type ¶
|
HAL1 |
HAL2 |
|---|---|
HAL_UARTEx_GetRxEventType(const UART_HandleTypeDef *huart)
|
Function removed in HAL2 as users now directly retrieve
the RX event type as a parameter in the callback function:
HAL_UART_RxCpltCallback(hal_uart_handle_t *huart, uint32_t size_byte,
hal_uart_rx_event_types_t rx_event).
|